Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ox_lib, core exports, switch notify, network vehicles #4

Closed
wants to merge 2 commits into from
Closed

Conversation

mafewtm
Copy link
Member

@mafewtm mafewtm commented Oct 5, 2023

Description

Further implementation of ox_lib, switch to code exports and notification exports, and set up vehicle spawning server side.

Vehicle spawning works now but object spawning still DOES NOT. Other than oxifying camera.lua, I have not fiddled with the object spawning as I am not sure how you'd like to deal with the server sided spawning for them. This is another resource which needs to be refactored further.

Checklist

  • I have personally loaded this code into an updated Qbox project and checked all of its functionality.
  • My code fits the style guidelines.
  • My PR fits the contribution guidelines.

Copy link
Contributor

@BerkieBb BerkieBb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generalized comments as all of them apply to multiple instances

end
end

elseif #(pos - vector3(Config.Locations.inside.coords.x, Config.Locations.inside.coords.y, Config.Locations.inside.coords.z)) < 1.5 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Config.Locations.inside.coords.xyz instead, same for all the other instances

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like it done that way or just .coords?

lib.hideTextUI()
end,
inside = function()
if IsPedInAnyVehicle(cache.ped, false) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of IsPedInAnyVehicle everywhere you can just check if cache.vehicle is not false (aka if cache.vehicle then)

mic_net = netid
holdingMic = true
else
ClearPedSecondaryTask(GetPlayerPed(PlayerId()))
ClearPedSecondaryTask(GetPlayerPed(cache.playerId))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetPlayerPed(cache.playerId) everywhere is useless when you have cache.ped

local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(PlayerId()), 0.0, 0.0, -5.0)
local camspawned = CreateObject(GetHashKey(camModel), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(cache.playerId), 0.0, 0.0, -5.0)
local camspawned = CreateObject(camModel, plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to wrap camModel in joaat to make this work

DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0, 44, true) -- INPUT_COVER
DisableControlAction(0,37,true) -- INPUT_SELECT_WEAPON
SetCurrentPedWeapon(PlayerPedId(), GetHashKey("WEAPON_UNARMED"), true)
SetCurrentPedWeapon(cache.ped, joaat("WEAPON_UNARMED"), true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When converting literal strings to a hash, use `` around the string instead of quotes to do it faster

DisableControlAction(0,25,true) -- disable aim
DisableControlAction(0, 44, true) -- INPUT_COVER
DisableControlAction(0,37,true) -- INPUT_SELECT_WEAPON
SetCurrentPedWeapon(PlayerPedId(), GetHashKey("WEAPON_UNARMED"), true)
SetCurrentPedWeapon(cache.ped, joaat("WEAPON_UNARMED"), true)
Wait(7)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to wait 0 as well, as waiting 7 will cause issues for the high end users

local scaleform = lib.requestScaleformMovie("security_camera")
local scaleform2 = lib.requestScaleformMovie("breaking_news")

local vehicle = GetVehiclePedIsIn(cache.ped)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cache.vehicle

SetCamFov(cam2, fov)
RenderScriptCams(true, false, 0, 1, 0)
PushScaleformMovieFunction(scaleform, "SET_CAM_LOGO")
PushScaleformMovieFunction(scaleform2, "breaking_news")
PopScaleformMovieFunctionVoid()
while newscamera and not IsEntityDead(lPed) and (GetVehiclePedIsIn(lPed) == vehicle) and true do
while newscamera and not IsEntityDead(cache.ped) and (GetVehiclePedIsIn(cache.ped) == vehicle) and true do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the last true as it's useless

local bmicspawned = CreateObject(GetHashKey(bmicModel), plyCoords.x, plyCoords.y, plyCoords.z, true, true, false)
lib.requestModel(bmicModel)
local plyCoords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(cache.playerId), 0.0, 0.0, -5.0)
local bmicspawned = CreateObject(bmicModel, plyCoords.x, plyCoords.y, plyCoords.z, true, true, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use joaat on bmicModel for this to work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt this already take place with lib.requestModel?

@mafewtm mafewtm closed this by deleting the head repository Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants